import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {

    private static String fun(String s){
        StringBuilder stringBuilder = new StringBuilder();

        //遍历字符串
        int i = 1;
        for (; i < s.length(); i++) {

            if (s.charAt(i - 1) != s.charAt(i)) {
                stringBuilder.append(s.charAt(i - 1));
            } else {
                i++;
            }
        }
        //拼接末尾
        int len = s.length();

        if(i == len)
            stringBuilder.append(s.charAt(s.length() - 1));
        //返回值
        return stringBuilder.toString();

    }
    private static boolean isfun1(String str){
        int left = 0;
        int right = str.length() -1;

        while(left < right){
            if(str.charAt(left) == str.charAt(right)){
                left++;
                right--;
            }else if(str.charAt(left) == str.charAt(left+1) && str.charAt(right -1) == str.charAt(right -1)){
                left += 2;
                right -= 2;
            }else{
                return false;
            }
        }
        return true;
    }


    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();

            //如果是对称结构就不需要拼接
            if (isfun1(s) && s.length() % 2 == 0) {
                System.out.println(0);
                continue;
            }
            String s1 = fun(s);
            String s2 = fun(s1);
            if (s2.length() == 0) {
                System.out.println(0);
            } else{
                String s3 = fun(s2);
                if (s3.length() == 0) {
                System.out.println(0);
                } else
                System.out.println(s3);
            }

        }

    }



   static ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {

        //1.将两个数据排序
       nums1.sort(new Comparator<Integer>() {
           @Override
           public int compare(Integer o1, Integer o2) {
               return o1 - o2;
           }
       });
       nums2.sort(new Comparator<Integer>() {
           @Override
           public int compare(Integer o1, Integer o2) {
               return o1 - o2;
           }
       });

        //2.遍历数组
        int len1 = nums1.size();
        int len2 = nums2.size();
        int i = 0;
        int j = 0;
        ArrayList<Integer> ret = new ArrayList<>();
        while(i < len1 && j < len2){
            if(nums1.get(i) == nums2.get(j) && !ret.contains(nums1.get(i))){
                ret.add(nums1.get(i));
                i++;
                j++;
            }else if(nums1.get(i) != nums2.get(j) && nums1.get(i) > nums2.get(j) ){
                j++;
            }else{
                i++;
            }
        }

        return ret;

    }

    public static void main(String[] args) {
        ArrayList<Integer> nums1 = new ArrayList<>();
        ArrayList<Integer> nums2 = new ArrayList<>();

        nums1.add(1);
        nums1.add(2);
        nums1.add(2);
        nums2.add(2);
        nums2.add(2);
        nums2.add(2);
        nums2.add(3);
        nums2.add(2);

        ArrayList<Integer> ret = intersection(nums1,nums2);

    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) {
            int a = in.nextInt();
            int b = in.nextInt();

            //创建一个统计的函数
            int cnt = count(a,b);
            System.out.println(cnt);
        }
    }

    //函数
    private static int count(int a,int b){
        int ret = 0;
        for(int i = a;i <= b;i++){

            ret += func(i);
        }
        return ret;
    }
    private static int func(int n){
        int count = 0;
        while(n > 0){
            if(n % 10 == 2){
                count++;
            }
            n /= 10;
        }
        return count;
    }
}